#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Desc: 上下文管理

import os

fp = './test.txt'
if os.path.exists(fp):
    os.remove(fp)
for _ in range(100):
    with open ('test.txt', 'a') as f:
        f.write('hello %s \n' % str(_ + 1))


f = open(fp, 'w')
try:
    f.write('hello by `try - finally`')
finally:
    f.close()
    # pass
